<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>vue路由7</title>
    <script src="../../js/vue3.js"></script>
    <script src="../../js/vue-router.global.js"></script>
    <style>
        #app {
            margin: 5rem auto;
            width: 35%;
        }
        
        * {
            padding: 0;
            margin: 0;
        }
        
        .box {
            border: 1px gray solid;
        }
        
        .row {
            display: flex;
            justify-content: space-around;
        }
        
        .tap {
            width: 50%;
            background-color: lightgray;
            border: 1px gray solid;
            font-size: 1.2rem;
            text-align: center;
            padding: 1rem;
        }
        
        .contents {
            height: 7rem;
            padding: 1rem;
            font-size: 1.5rem;
        }
        
      
    </style>
</head>

<body>
    <!-- 运行 -->
    <div id="app">
        <div class="box">
            <div class="row">
                <div class="tap">
                    <p @click="deliver">发送</p>
                </div>
               <div class="tap">
                    <p @click="back">撤回</p>
               </div>
                
            </div>
            <div class="contents">
                <router-view></router-view>
            </div>
        </div>

    </div>
    <!-- 模版 -->
    <template id="body">
        {{this.$route.params.test}}
    </template>
    <script>
        const v_app = Vue.createApp({
            data() {
                return {

                }
            },
            methods:{
                deliver(){
                    this.$router.push({
                        name:"names",
                        params:{
                            test:"czy"
                        }
                    });
                },
                back(){
                    this.$router.go(-1);
                }
            }
        });
        const body = {
            template: "#body",
        }
        const routes = [{
            name:"names",
            path: "/names/:test",
            component:body
        },]
        const router = VueRouter.createRouter({
            history: VueRouter.createWebHashHistory(),
            routes: routes
        });
        v_app.use(router);
        v_app.mount("#app");
    </script>
</body>

</html>